package Util;

import com.mchange.v2.c3p0.ComboPooledDataSource;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class JDBCtool {
    private static DataSource dataSource;
    static {
        dataSource =new ComboPooledDataSource("testc3p0");
    }
    public static Connection getConnection() throws SQLException {
        Connection connection = dataSource.getConnection();
        return connection;
    }
    public static void release(Connection connection, Statement statement, ResultSet resultSet) throws SQLException {
        if(connection!=null){
            connection.close();
        }
        if(statement!=null)
        {
            statement.close();
        }
        if(resultSet!=null){
            resultSet.close();
        }
    }

    /*public static void main(String[] args) throws SQLException {
        System.out.println(getConnection());
    }*/
}
